

import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;

public class Test {
    public static boolean isValid(String s) {
        Stack<Character> st = new Stack<>();
        for(int i=0;i<s.length();i++) {
            char t = s.charAt(i);
            if(t=='('||t=='['||t=='{'){
                st.push(t);
            }else {
                if(st.empty()) {
                    return false;
                }else {
                    char c = st.pop();
                    if((c=='('&&t!=')') || (c=='['&&t!=']') || (c=='{'&&t!='}')){
                        return false;
                    }
                }
            }
        }
        return st.empty();
    }

    public static void main2(String[] args) {
        //System.out.println(isValid("(]"));
        Queue<Integer> queue = new LinkedList<>();
        queue.offer(1);
        queue.offer(2);
        queue.offer(3);
        queue.offer(4);

        queue.poll();
        int ret = queue.peek();
        System.out.println(ret);
        System.out.println(queue.poll());
        System.out.println(queue.poll());
        System.out.println(queue.poll());

    }

    public static void main(String[] args) {
        MinStack2 minStack2 = new MinStack2();
        minStack2.push(512);
        minStack2.push(-1024);
        minStack2.push(-1024);
        minStack2.push(512);
        minStack2.pop();
        System.out.println(minStack2.getMin());
        minStack2.pop();
        System.out.println(minStack2.getMin());
        minStack2.pop();
        System.out.println(minStack2.getMin());
    }

    public boolean IsPopOrder (int[] pushV, int[] popV) {
        Stack<Integer> stack = new Stack<>();
        int j = 0;
        for(int i=0;i<pushV.length;i++) {
            if(pushV[i]!=popV[j]) {
                stack.push(pushV[i]);
            }
            while(j<popV.length && stack.peek() == popV[j]){
                stack.pop();
                j++;
            }
        }
        return stack.isEmpty();
    }
}













